package pencil.util;


import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

import oracle.sql.BINARY_DOUBLE;


public class pencilUtil {

		private pencilUtil(){}
		/**
		 * 호출된 시점의 일시를 14자리 String 값으로 만들어 return
		 * 예) 20120512100524 (yyyyMMddHHmmss)
		 * @return
		 */
		public static String getNow(){
			Date date = new Date();
			SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd.HH:mm:ss");
			return format.format(date);
		}
	
		public static int troubleMaker(int basicNum, int randomNum){
		//////////////////////불량 판정
		//ex)i=기본값(80)+랜던값(0~20)	
			int result=basicNum+(int)(Math.random()*randomNum)+1;
			return result;
		}
	/////
		
		public static int runStep(int now1, int mark){
			BigDecimal a1=new BigDecimal(100);//주분량
			BigDecimal a2=new BigDecimal(mark);//퍼센트수치
			BigDecimal c1=new BigDecimal(now1);//
			BigDecimal d1;//퍼센트 수치
			BigDecimal d2;//퍼센트 계산
			
			d1= a2.divide(a1,1,BigDecimal.ROUND_UP);//올림
			d2= c1.divide(d1, 0, BigDecimal.ROUND_UP);
			String x1=d2.toString();
			int c3= Integer.parseInt(x1);
			return c3;
		}
		
		public static double HolerunStep(int mark){
			BigDecimal a1=new BigDecimal(100);//주분량
			BigDecimal a2=new BigDecimal(mark);//퍼센트수치
			BigDecimal c1;//
			BigDecimal b1;//현재생성량
			BigDecimal c2;//
			
			c1= a1.divide(a2,0,BigDecimal.ROUND_UP);//올림
//			c2= b1.divide(c1, 0, BigDecimal.ROUND_UP);
			String x1=c1.toString();
			double c3= Double.parseDouble(x1);
			
			return c3;
		}
		
		public static String timeUsed(int endSec){
			BigDecimal a1=new BigDecimal(endSec);//주분량
			BigDecimal a2=new BigDecimal(60);//퍼센트수치
			BigDecimal d1;//퍼센트 계산	
			d1= a1.divide(a2,0,BigDecimal.ROUND_DOWN);//버림	
			String x1=d1.toString();//분
			int sec=endSec%60;//초			
			return x1 +"분 " + sec +"초";
		}
		
		
		
		public static void main(String [] arg)throws Exception{
			
		
			 //System.out.println(HolerunStep(120));
			
		}
}
